library PlayDead initializer init requires LegacySystem

	private function PlayDeadConditions takes nothing returns boolean
		return GetSpellAbilityId()=='A05Y'
	endfunction

	private function PlayDead takes nothing returns nothing
		local unit u = GetTriggerUnit()
		call IssueImmediateOrder(u,"holdposition")
		call SetUnitAnimation(u,"death")
		set bj_meleeNearestMineDist = GetUnitX(u)
		set bj_lastTransmissionDuration = GetUnitY(u)
		set udg_soundpath = "Units\\Critters\\Sheep\\SheepDeath.wav"
		call PlaySoundPath3D.execute()
		call SetUnitInvulnerable(u,true)
		call PauseUnit(u,true)
		call PolledWait(6.)
		call PauseUnit(u,false)
		call SetUnitInvulnerable(u,false)
		call ResetUnitAnimation(u)
		set u = null
	endfunction
	
	
	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger()
		call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
		call TriggerAddCondition(t,Condition(function PlayDeadConditions))
		call TriggerAddAction(t,function PlayDead)
	endfunction



endlibrary